// 引入css样式
require("../../assets/css/common.css");
require("../../assets/font_44fp3ls0tzq/iconfont.css");
require("../../assets/css/reset.css");
require("../../assets/css/normalize.css");
require("../../assets/css/tabbar.less");
require("./mime.less");

// 引入模块
const dom = require("../../utils/dom.js");
const axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	// 底部导航栏
	dom.tabBar("mime");

	//获取运动数据
	axios.get("/api/exercise").then((res) => {
		let data = res.data.data;
		dom.get("#all i").textContent = data.sum7Duration;
		dom.get("#consume i").textContent = data.sum7Calorie;
	});

	//退出登录
	dom.get("#out").addEventListener("click", function () {
		location.href = "register.html";
	});

	//实现头部个人信息跳转
	dom.get("#username").addEventListener("click", function () {
		location.href = "mime_change.html";
	});

	//运动数据页面跳转
	dom.get("#jiantou").addEventListener("click", function () {
		location.href = "mime_sports_data.html";
	});

	//点击跳转徽章
	//点击返回上一页
	dom.get("#jiantou2").addEventListener("click", function () {
		location.href = "mime_badge.html";
	});

	//显示个人信息
	axios.get("/api/user/info").then((res) => {
		let data = res.data.data;
		dom.get("#avator").src = axios.defaults.baseURL + data.imgUrl;
		dom.get("#username1").textContent = data.nickName;
		dom.get("#sign").textContent = data.sign;
	});
});
